package com.web.servlet.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.web.servlet.bean.PlatformGameBean;


public class PlatformGameListConnect {

	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		 
		//DBConnect.queryAllUser();
		//Player player =DBConnect.queryOneUserByUserId("10000");
		//Player player =DBConnect.queryOneUserByUserName("ff","ff");
		//DBConnect.updateUserNikeByUserId("10000","被高兴");
		//Player player =DBConnect.insertOneUser("nihao22","nihao1","很好");
		//DBConnect.updateUserCoinByUserId("10000",2000);
		//System.out.println("userId="+player.getId()+"    userName="+player.getName());
		//DBConnect.deleteUserByUserId("10003");
		
	}

	
	//查询所有游戏列表
	public static List<PlatformGameBean> queryAllPlatformGameList()
	{
		List<PlatformGameBean> platformGameList =new ArrayList<PlatformGameBean>();
		try
		{
			Connection con = DBConnect.connDataBase();
            //2.创建statement类对象，用来执行SQL语句！！
            Statement statement = con.createStatement();
            //要执行的SQL语句
            String sql = "select * from PlatformGameList";
            //3.ResultSet类，用来存放获取的结果集！！
            ResultSet rs = statement.executeQuery(sql);  
        
            while(rs.next())
            {
            	PlatformGameBean platformGameBean = new PlatformGameBean();
            	platformGameBean.setId(rs.getInt("gameId"));
            	platformGameBean.setNameCn(rs.getString("gameNameCn"));
            	platformGameBean.setNameEn(rs.getString("gameNameEn"));
            	platformGameBean.setServeIp(rs.getString("gameIp"));
            	platformGameBean.setPort(rs.getInt("gamePort"));
            	platformGameBean.setVersion(rs.getString("gameVersion"));
            	platformGameBean.setIconVersion(rs.getInt("gameIconVersion"));
            	platformGameBean.setGameDownUrl(rs.getString("gameDownUrl"));
            	platformGameBean.setGameDownIconUrl(rs.getString("gameIconDownUrl"));
            	platformGameBean.setWebUrl(rs.getString("webUrl"));
            	platformGameBean.setIsVis(rs.getInt("isVis"));
            	platformGameList.add(platformGameBean);
            }
           DBPoolManager.closeConn(con);
           if (rs!=null)
        	   rs.close();
           if (con!=null)
        	   con.close();
           if (statement!=null)
        	   statement.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
		return platformGameList;
	}
}
